package com.reader.cms.entity.sys;

import com.baomidou.mybatisplus.activerecord.Model;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.IdType;
import com.reader.core.validator.group.AddGroup;
import com.reader.core.validator.group.UpdateGroup;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.NotBlank;
import java.io.Serializable;
import java.util.Date;
import java.util.List;


/**
 * @author jiahaikun
 * @@description
 * @date 2018-08-06
 */
@TableName("sys_organization")
public class SysOrganization extends Model<SysOrganization> {

    private static final long serialVersionUID = 1L;


    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

    @TableField("parent_code")
    private String parentCode;

    @NotBlank(message="机构编码不能为空！！！", groups = {AddGroup.class, UpdateGroup.class})
    private String code;

    @NotBlank(message="机构名称不能为空！！！", groups = {AddGroup.class, UpdateGroup.class})
    private String name;


    private Integer enable;


    @TableField("last_level_flag")
    private String lastLevelFlag;

    @TableField("del_flag")
    private Integer delFlag;


    @DateTimeFormat(pattern = "yyyy-MM-dd hh:mm:ss")
    @TableField("insert_dt")
    private Date insertDt;

    @TableField("insert_user_id")
    private Integer insertUserId;


    @DateTimeFormat(pattern = "yyyy-MM-dd hh:mm:ss")
    @TableField("updt_dt")
    private Date updtDt;

    @TableField("updt_user_id")
    private Integer updtUserId;


    private String remark;

    //子机构
    @TableField(exist = false)
    private List<SysOrganization> children;

    //角色ID
    @TableField(exist = false)
    private List<Integer> roleIds;

    @TableField(exist = false)
    private String roles;

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getParentCode() {
        return parentCode;
    }

    public void setParentCode(String parentCode) {
        this.parentCode = parentCode;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer  getEnable() {
        return enable;
    }

    public void setEnable(Integer enable) {
        this.enable = enable;
    }

    public String getLastLevelFlag() {
        return lastLevelFlag;
    }

    public void setLastLevelFlag(String lastLevelFlag) {
        this.lastLevelFlag = lastLevelFlag;
    }

    public Integer getDelFlag() {
        return delFlag;
    }

    public void setDelFlag(Integer delFlag) {
        this.delFlag = delFlag;
    }

    public Date getInsertDt() {
        return insertDt;
    }

    public void setInsertDt(Date insertDt) {
        this.insertDt = insertDt;
    }

    public Integer getInsertUserId() {
        return insertUserId;
    }

    public void setInsertUserId(Integer insertUserId) {
        this.insertUserId = insertUserId;
    }

    public Date getUpdtDt() {
        return updtDt;
    }

    public void setUpdtDt(Date updtDt) {
        this.updtDt = updtDt;
    }

    public Integer getUpdtUserId() {
        return updtUserId;
    }

    public void setUpdtUserId(Integer updtUserId) {
        this.updtUserId = updtUserId;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }


    public List<SysOrganization> getChildren() {
        return children;
    }

    public void setChildren(List<SysOrganization> children) {
        this.children = children;
    }

    public List<Integer> getRoleIds() {
        return roleIds;
    }

    public void setRoleIds(List<Integer> roleIds) {
        this.roleIds = roleIds;
    }

    public String getRoles() {
        return roles;
    }

    public void setRoles(String roles) {
        this.roles = roles;
    }

    @Override
    protected Serializable pkVal() {
        return this.id;
    }

    @Override
    public String toString() {
        return "SysOrganization{" +
                ", id=" + id +
                ", parentCode=" + parentCode +
                ", code=" + code +
                ", name=" + name +
                ", enable=" + enable +
                ", lastLevelFlag=" + lastLevelFlag +
                ", delFlag=" + delFlag +
                ", insertDt=" + insertDt +
                ", insertUserId=" + insertUserId +
                ", updtDt=" + updtDt +
                ", updtUserId=" + updtUserId +
                ", remark=" + remark +
                "}";
    }
}